package com.pap.sequencedemo;

import com.pap.sequence.sequence.service.ISequenceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RestController;

@SpringBootApplication
@RestController
public class PapSequenceStarterDemoApplication {

    public static void main(String[] args) {
        SpringApplication.run(PapSequenceStarterDemoApplication.class, args);
    }

    @Autowired(required = false)
    private ISequenceService sequenceService;

    @GetMapping(value = "/db/{id}")
    public String selectDB(@RequestHeader(value = "papToken", defaultValue = "-1") String papToken,
                           @RequestHeader(value = "papVersion", defaultValue = "1.0") String papVersion,
                           @PathVariable("id") String id) {

        String seqNo = sequenceService.selectNextSimpleSequence(id);

        return seqNo;
    }
}
